package io.renren.modules.base.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


import io.jsonwebtoken.Claims;
import io.renren.modules.app.utils.JwtUtils;

/**
 * @author kk
 * JWT,token 生成 获取
 */
@Component
public class JwtOperation  {
	
	@Autowired
	JwtUtils jWTUtil;


	//@Autowired
	//private WxUserService wxUserService;
	
	
	@SuppressWarnings("static-access")
	public String createToken(Long userId){
		String generateToken = jWTUtil.generateToken(userId);
		return generateToken;
	}
	
	
	@SuppressWarnings("static-access")
	public String getToken(String token){
		Claims claimByToken = jWTUtil.getClaimByToken(token);
		Object object = claimByToken.get("userId");
		return object.toString();
	}

	
	/**
	@SuppressWarnings("static-access")
	public WxUserEntity getUser(String token){
		if(token!=null){
			Claims claimByToken = jWTUtil.getClaimByToken(token);
			Object object = claimByToken.get("userId");

			if(null!= Long.valueOf(object.toString())){
				return wxUserService.selectById(Long.valueOf(object.toString()));
			}
		}
		 return null;
	}
	**/
}
